package com.cleverdevices.kevin;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Menu extends ListActivity{
	
	String classes[] = {"StartingPoint", "example1", "example2", 
			"example3", "example4", "example5", "example6"};
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
	}
	
	

	@Override
	/**
	 * This method starts a class according to the item that is clicked.
	 * @parameters l which list view is clicked
	 *  v which view is clicked
	 *  position the position within the listView that was clicked. Corresponds to string array
	 *  id some id...no idea what it's for
	 */
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		
		String cheese = classes[position];
		try{
			//Class.forName returns a class with the specified name
			Class<?> ourClass = Class.forName("com.cleverdevices.kevin." + cheese);	//starts an intent through Java and not referencing an XML
			Intent ourIntent = new Intent(Menu.this, ourClass);						//Menu.this is our context and ourClass is the intent
			startActivity(ourIntent);												//starting a new activity (and needs an intent to be passed)
		}
		catch(ClassNotFoundException e){
			e.printStackTrace();	
		}
	}
}
